home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5379 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.2 KB

  1. Path: anvil.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: What does the -O option do???!!!
  5. Date: 12 Feb 1996 10:43:35 -0800
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4fo1onINNlma@anvil.ugrad.cs.ubc.ca>
  8. References: <4ehger$cj9@mark.ucdavis.edu> <9602102332.AA09466@dxmint.cern.ch> <4flhrhINNtj@keats.ugrad.cs.ubc.ca> <9602120013.AA06318@ues5.cern.ch>
  9. NNTP-Posting-Host: anvil.ugrad.cs.ubc.ca
  10.  
  11. In article <9602120013.AA06318@ues5.cern.ch>, Dan Pop  <Dan.Pop@cern.ch> wrote:
  12.  >c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) writes:
  13.  >
  14.  >>In article <9602102332.AA09466@dxmint.cern.ch>,
  15.  >>Dan Pop  <danpop@mail.cern.ch> wrote:
  16.  >>>c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) writes:
  17.  >>>
  18.  >>>>... as long as it is not hard-coded to treat identifiers like "free" specially. 
  19.  >>>
  20.  >>>A compiler is free to treat identifiers like "free" specially after the
  21.  >>>relevant header has been included.
  22.  >>>
  23.  >>>>If you write your own free() with different semantics, you would not want the
  24.  >>>>compiler messing with that. 
  25.  >>>
  26.  >>>If you write your own free() you invoke undefined behaviour and you can't
  27.  >>>expect the compiler to behave in a sensible way.  The implementation 
  28.  >>>namespace is a big taboo in C.
  29.  >>
  30.  >>Are you serious? What if I'm writing a little embedded kernel that doesn't use
  31.  >>anything resembling the standard C library, and I use free() for something
  32.  >>quite different?
  33.  >
  34.  >Could you, please, actually read the standard before continuing to post
  35.  >on this thread?  You'll find there a clear distinction between freestanding
  36.  >and hosted environments.
  37.  
  38. Ah ok. So in effect there is a sort of "switch" to turn off the special
  39. treatment of things like memcpy(). I mean, it's nice that some things can be
  40. optimized by the compiler when the standard allows it to treat certain
  41. functions as though they were operators, so that memcpy() is translated into
  42. inline code. What I said was that it's desirable to turn it off. By allowing
  43. for the freestanding environment distinction, the standard allows this---I see
  44. it now. I wouldn't want to give up the optimization of memcpy() for religious
  45. reasons. :)
  46. -- 
  47.  
  48.